import type { R, TableDataInfo } from '@/api/model/resultModel';
import type { XyywCouponForm, XyywCouponQuery, XyywCouponVo } from '@/api/xyyw/model/couponModel';
import { request } from '@/utils/request';

// 查询优惠券列表
export function listCoupon(query?: XyywCouponQuery) {
  return request.get<TableDataInfo<XyywCouponVo>>({
    url: '/xyyw/coupon/list',
    params: query,
  });
}

// 查询优惠券详细
export function getCoupon(couponId: number) {
  return request.get<R<XyywCouponVo>>({
    url: `/xyyw/coupon/${couponId}`,
  });
}

// 新增优惠券
export function addCoupon(data: XyywCouponForm) {
  return request.post<R<void>>({
    url: '/xyyw/coupon',
    data,
  });
}

// 修改优惠券
export function updateCoupon(data: XyywCouponForm) {
  return request.put<R<void>>({
    url: '/xyyw/coupon',
    data,
  });
}

// 删除优惠券
export function delCoupon(couponIds: number | Array<number>) {
  return request.delete<R<void>>({
    url: `/xyyw/coupon/${couponIds}`,
  });
}
